<?php if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Lookup_v1 extends CI_Controller
{

    function lookup_v1()
    {
        parent::__construct();
        $this->load->library('session');
        $this->load->library('form_validation');
        $this->load->library('encrypt');
        $this->load->model('mmaster');
        $this->load->model('mservices');
        $this->load->model('mholiday');
        $this->load->model('mlookupv1');
        
        $this->load->model('mglobal');
        $this->is_logged_in();
        #$this->mjadwal->saveLog();
    }

    function is_logged_in()
    {
        $is_logged_in = $this->session->userdata('is_logged_in');
        if (!isset($is_logged_in) || $is_logged_in != true) {
            redirect(base_url() . 'index.php/login');
        }
    }

    function identityType($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-identity';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'Identity type', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "identity_type";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'identity_type');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/identityType");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function gender($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-gender';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'gender', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "gender";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'gender');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/gender");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
        function maritalStatus($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-maritalStatus';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'marital_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "marital_status";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'marital_status');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/maritalStatus");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function outletLocation($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-outletLocation';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'outlet_location', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "outlet_location";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'outlet_location');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/outletLocation");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }

    function outletStatus($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-outletStatus';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'outlet_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "outlet_status";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'outlet_status');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/outletStatus");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function outletType($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-outletType';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'outlet_type', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "outlet_type";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'outlet_type');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/outletType");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function educationType($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-educationType';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'education_type', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "education_type";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'education_type');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/educationType");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function frontlinerType($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-frontlinerType';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'frontliner_type', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "frontliner_type";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'frontliner_type');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/frontlinerType");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function outletSize($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-outletSize';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'outlet_size', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "outlet_size";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'outlet_size');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/outletSize");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function position($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-position';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'position', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "position";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'position');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/position");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function tipeOutlet($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-tipeOutlet';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'tipe_outlet', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "tipe_outlet";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'tipe_outlet');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/tipeOutlet");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function passwordMinLen($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-passwordMinLen';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'account_min_length', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "account_min_length";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'account_min_length');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/passwordMinLen");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function maxUserAtt($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-maxUserAtt';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'account_max_attemp', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "account_max_attemp";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'account_max_attemp');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/maxUserAtt");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function jourCyclMin($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-jourCyclMin';
        $data['proses'] = $proses;
        $data['id'] = $id;
        $data['combo_box'] = $this->mlookupv1->getCombo('min');

        /**$data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }*/
        
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('kelas_outlet', 'kelas outlet', 'required');
        $this->form_validation->set_rules('lookup_value_min', 'minimal kunjungan', 'required|numeric|greater_than[0]|less_than[32]');
        $this->form_validation->set_rules('lookup_value_max', 'maximal kunjungan', 'required|numeric|greater_than[0]|less_than[32]');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');


        $kelasOutlet = $this->input->post("kelas_outlet");
        $lookup_value_min = $this->input->post("lookup_value_min");
        $lookup_value_max = $this->input->post("lookup_value_max");
        $userid = $this->session->userdata('username');
        $key = "jc_sfa_min";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_kunjungan_jc_outlet_insupd($kelasOutlet,$lookup_value_min,$lookup_value_max,$userid);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/jourCyclMin");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function jourCyclMax($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-jourCyclMax';
        $data['proses'] = $proses;
        $data['id'] = $id;
        $data['combo_box'] = $this->mlookupv1->getCombo('max');

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('kelas_outlet', 'kelas outlet', 'required');
        $this->form_validation->set_rules('lookup_value_min', 'minimal kunjungan', 'required|numeric|greater_than[0]|less_than[32]');
        $this->form_validation->set_rules('lookup_value_max', 'maximal kunjungan', 'required|numeric|greater_than[0]|less_than[32]');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $kelasOutlet = $this->input->post("kelas_outlet");
        $lookup_value_min = $this->input->post("lookup_value_min");
        $lookup_value_max = $this->input->post("lookup_value_max");
        $userid = $this->session->userdata('username');
        $key = "jc_sfa_max";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_kunjungan_jc_outlet_insupd($kelasOutlet,$lookup_value_min,$lookup_value_max,$userid);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/jourCyclMax");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function outletClassAmount($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-outletClassAmount';
        $data['proses'] = $proses;
        $data['id'] = $id;
        $data['region'] = $this->mlookupv1->getRegion();
        $data['territory'] = $this->mlookupv1->getTerr($this->session->userdata('username'));
        $terr_name = $this->mlookupv1->getTerr($this->session->userdata('username'));
        $data['terr_name'] = $this->mlookupv1->getTerrName($terr_name->f_get_cluster);
        //$data['combo_box'] = $this->mlookupv1->getCombo('max');
        $key = "outlet_class_amount";
        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id, $key);
                $data['data']['param_desc'] = $getdata->param_desc;
                $data['data']['param_value'] = $getdata->param_value;
                $data['data']['start_period'] = $getdata->start_period;
                $data['data']['end_period'] = $getdata->end_period;
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('territory_name', 'territory_name', 'required');
        $this->form_validation->set_rules('param_desc', 'kelas', 'required'); 
        $this->form_validation->set_rules('param_value', 'amount', 'required|numeric'); 
        $this->form_validation->set_rules('start_period', 'mulai', 'required');
        $this->form_validation->set_rules('end_period', 'akhir', 'required');              

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("param_value");
        

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'outlet_class_amount');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/outletClassAmount");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function religion($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-religion';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'religion', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "religion";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'religion');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/religion");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function sizeOfBusiness($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-sizeOfBusiness';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'size_of_business', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "size_of_business";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'size_of_business');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/sizeOfBusiness");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function agentStatus($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-agentStatus';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "agent_status";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, 'agent_status');
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/agentStatus");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function businessFocus($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-businessFocus';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "business_focus";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/businessFocus");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function businessStructure($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-businessStructure';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "business_structure";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/businessStructure");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function channel($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-channel';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "channel";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/channel");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function customerType($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-customerType';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "customer_type";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/customerType");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function fullBrandingBy($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-fullBrandingBy';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "full_branding_by";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/fullBrandingBy");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function outletOwnership($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-outletOwnership';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "outlet_ownership";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/outletOwnership");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function salesType($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-salesType';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "sales_type";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/salesType");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function trackingInterval($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-trackingInterval';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "tracking_interval";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/trackinInterval");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function kpiTargetPeriod($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-kpiTargetPeriod';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "kpi_target_period";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/kpiTargetPeriod");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }
    
    function kpiPercentage($proses = "", $id = "")
    {
        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-kpiPercentage';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        //$data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
            
        }
        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('lookup_value', 'agen_status', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "kpi_percentage";

        if ($this->form_validation->run() != false) {
            // masukkan data di sini
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);
            if($proses == "create")
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/kpiPercentage");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }

    ########################################################################
    ########################################################################
    public function getById($id)
    {
        if (isset($id))
            echo json_encode($this->mholiday->get($id));
    }

    public function read($key)
    {
        if($key == "outlet_class_amount")
        {
            echo json_encode($this->mlookupv1->getCustomParam($key, $this->session->userdata('username')));    
        }
        else if($key == "program") //added by: alfin akhret
        {
            echo json_encode($this->mlookupv1->getProgram($key));    
        }
        else
        {
            echo json_encode($this->mlookupv1->getKey($key));    
        }
        
    }
    
    public function getCluster($region_id)
    {
        echo json_encode($this->mlookupv1->getCluster($region_id));       
    }

    public function delete($key = "", $id = null)
    {
        $proses = "delete";
        if (is_null($id)) {
            echo 'ERROR: Id not provided.';
            return;
        }
        
        if($key == "jc_sfa_min" || $key == "jc_sfa_max")
        {
            
        }
        else
        {
            $this->mlookupv1->sp_lookup_cud($proses, $id, $key);    
        }
        echo 'Records deleted successfully';
    }

    //created by : alfin akhret
    public function program($proses = "", $id = "")
    {

        $data['template'] = "shell/smooth-side";
        //$data['users'] = $this->mlookupv1->getKey('identity_type', $id);
        $data['main_view'] = 'f-lookup-program';
        $data['proses'] = $proses;
        $data['id'] = $id;

        $data['data']['lookup_value'] = "";
        $data['data'] = array("tanggal" => "", "keterangan" => "");
        if ($proses <> "" && $id <> "") {
                $getdata = $this->mlookupv1->getById($id);
                $data['data']['lookup_value'] = $getdata->lookup_value;        
        }

        //jika ada proses
        if($proses == 'new')
        {
            //cek jabatan
            $group_id = $this->mlookupv1->cek_jabatan_user($this->session->userdata('username'));
            $data['job_title'] = (($group_id[0]->user_group_id == '10') || ($group_id[0]->user_group_id == '4')) ? $group_id[0]->user_group_id : false;
            // $data['territory_id'] = ($data['job_title'] == '4')? $this->mlookupv1->get_current_territory($this->session->userdata('username')):null;
            if($data['job_title'] == '4')
            {
               $data['territory_id'] = $this->mlookupv1->get_current_territory($this->session->userdata('username'));
               foreach ($data['territory_id'] as $r) 
               {
                    $data['territory_id'] = $r->f_get_cluster;
               } 
            } 

            $data['tipe_program'] = $this->mlookupv1->get_program_type();
        }

        #inisialisasi elemen form yang harus diisi
        $this->form_validation->set_rules('nama_program', 'Nama Program', 'required');

        $this->form_validation->set_error_delimiters('<li>', '</li>');
        $this->form_validation->set_message('required', 'Kolom <b>%s</b> harus diisi.');

        $value = $this->input->post("lookup_value");
        $key = "agent_status";

        if ($this->form_validation->run() != false) {
            // data :
            $caption = $this->input->post('nama_program');
            $desc = $this->input->post('keterangan');
            $program_type_id = $this->input->post('tipe_program');
            $territory_id = $this->input->post('territory_id');
            $created_by = $this->session->userdata('username');

            // masukkan data di sini
            if($proses == "new")
            {
                $this->mlookupv1->insert_new_program($caption, $desc, $program_type_id, $territory_id, $created_by);
                $this->session->set_flashdata('message', 'Data berhasil dimasukkan');
            }
            else
            {
                $this->session->set_flashdata('message', 'Data '.$value.' pada '.$key.' berhasil diubah');   
            }
            redirect(base_url() . "index.php/lookup_v1/program");
        }

        $hasil = "";
        $this->load->view($data['template'], $data);
    }

    public function onOffProgram($program_id, $istatus)
    {
        $this->mlookupv1->onOffProgram($program_id, $istatus);
        redirect(base_url() . "index.php/lookup_v1/program");

    }
}
